package gui;

import java.awt.Color;
import java.awt.Graphics;

public class Trotteuse {
	private int x, y, width, height, count;
	private int startX, startY;
	private float cellW, cellH, increment;
	
	public Trotteuse(int x, int y, int width, int height) {
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		count = -1;
		
		startX = x + 2;
		startY = y + 2;
		cellW = ((float)width - 1F)/10F - 2F;
		cellH = (float)height - 3;
		increment = ((float)width - 1F)/10F;
	}
	
	public void computeAndDraw(Graphics g) {
		count++;
		
		g.setColor(Color.WHITE);
		g.fillRect(x, y, width, height);
		
		g.setColor(Color.BLACK);
		g.drawRect(x, y, width, height);
		
		for(int i = 0; i <= (count - 1)%10; ++i) {
			g.fillRect((int)((float)startX + (float)i * increment), startY, (int)cellW, (int)cellH);
		}
		
		g.drawString(String.valueOf(count), startX, startY + height + 15);
	}
}
